const KoaRouter = require('@koa/router')
const orderRouter = new KoaRouter({ 'prefix': '/order' })
const { auth } = require('../middleware/auth.middleware')
const { orderValidator } = require('../middleware/order.middleware')

const { create, findAll, update } = require('../controller/order.controller')
/**提交订单 */
orderRouter.post('/', auth, orderValidator({
  address_id: 'int',
  goods_info: 'string',
  total: 'string',
}), create)
/**获取订单列表 */
orderRouter.get('/', auth, findAll)

/**更新订单状态*/
orderRouter.patch(
  '/:id',
  auth,
  orderValidator({
    status: 'number',
  }),
  update
)
module.exports = orderRouter